home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK1.toast / Development Kits (Disc 1) / Open Transport / Sample Code / DLPI / OT DLPI Sample1.0B7 / Common Source / DLPIRoutines.h < prev    next >
Encoding:
Text File  |  1995-04-19  |  6.5 KB  |  169 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DLPIRoutines.h
  3.  
  4.     Contains:    This file contains the defines necessary for the STREAMS environment.
  5.  
  6.     Written by:    
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.  
  13.     To Do:
  14. */
  15.  
  16.  
  17. //-----------------------------------------------------------------------------------------
  18. // bit definitions for various flags used in the per stream data structure (streamFlags)
  19. //-----------------------------------------------------------------------------------------
  20. enum DLPIStreamFlags
  21.     {
  22.     kAutoXID                =    0x00000001,
  23.     kAutoTest                =    0x00000002,
  24.     kSnapStream                =    0x00000004,
  25.     kAcceptMulticasts        =    0x00000008,
  26.     kAcceptAll8022Packets    =    0x00000010,
  27.     kWriteRawPackets        =    0x00000020,
  28.     kReadRawPackets            =    0x00000040
  29.     };
  30.  
  31. //-----------------------------------------------------------------------------------------
  32. // Used to register Group SAP addresses
  33. //-----------------------------------------------------------------------------------------
  34. #define kGroupSAPMapSize    128/32        // number of 32 values we need for 128 bits    
  35. #define kGSshift            6
  36. #define kGSmask                0x1F
  37.  
  38. //-----------------------------------------------------------------------------------------
  39. // Internal Return codes for DLPI
  40. //-----------------------------------------------------------------------------------------
  41.  
  42. enum DLPIInternalCodes        
  43.     {
  44.     kdlpiDONE            = 1,
  45.     kdlpiRETRY            = 2
  46.     };
  47.  
  48. //-----------------------------------------------------------------------------------------
  49. // Timer Message Types
  50. //-----------------------------------------------------------------------------------------
  51.  
  52. enum TimerMessageTypes        
  53.     {
  54.     kEnableQueueTimerMsg    = 1
  55.     };
  56.  
  57. //-----------------------------------------------------------------------------------------
  58. // Write Scheduler Types
  59. //-----------------------------------------------------------------------------------------
  60.  
  61. enum DLPISchedulerType        
  62.     {
  63.     kdlpiBufcallType    = 1
  64.     };
  65.  
  66. //-----------------------------------------------------------------------------------------
  67. // Packet Types
  68. //-----------------------------------------------------------------------------------------
  69. enum PacketTypes        
  70.     {
  71.     kPktDIX                = 0,
  72.     kPkt8022SAP            = 1,
  73.     kPkt8022GroupSAP    = 2,
  74.     kPkt8022SNAP        = 3,
  75.     kPktIPX                = 4,
  76.     kPktUnknown            = 5
  77.     };
  78.  
  79. //-----------------------------------------------------------------------------------------
  80. // Ethernet length constants
  81. //-----------------------------------------------------------------------------------------
  82. #define kEnetPhysicalAddressLength     k48BitAddrLength    // 6 bytes for ethernet
  83. #define kEnetAndSAPAddressLength     kEnetPhysicalAddressLength + k8022DLSAPLength
  84. #define kMaxBoundAddrLength         6 + 2 + 5            // addr + sap + snap
  85.  
  86. //-----------------------------------------------------------------------------------------
  87. // New structures
  88. //-----------------------------------------------------------------------------------------
  89. struct T8022AddressStruct
  90.     {
  91.     UInt8            fHWAddr[k48BitAddrLength];
  92.     UInt16            fSAP;
  93.     UInt8            fSNAP[k8022SNAPLength];
  94.     };
  95. typedef struct T8022AddressStruct T8022AddressStruct;
  96.  
  97. //-----------------------------------------------------------------------------------------
  98. // One structure per stream for our dlpi
  99. //-----------------------------------------------------------------------------------------
  100.  
  101. struct DLPIStream 
  102.     {
  103.     struct DLPIStream     *nextStream;                // queue pointer for active streams 
  104.     struct DLPIStream     *rxPacketLink;                // streams that want a received packet 
  105.     queue_t                *readQueue;                    
  106.     UInt32                dlpiState;                    
  107.     UInt32                timeoutID;                    // id for bufcalls and timeouts 
  108.     UInt16                idType;                        // type of id (bufcall or timeout)
  109.     UInt16                minorDevice;
  110.     UInt16                dlsap;
  111.     UInt32                group_sap[kGroupSAPMapSize];
  112.     UInt32                streamFlags;                // 32 1 bit flags for the stream
  113.     QHdr                multicastQueue;
  114.     UInt8                snap[k8022SNAPLength];
  115.     mblk_t                *bufferTimerMsg;
  116.     };
  117.  
  118. typedef struct DLPIStream DLPIStream;
  119.  
  120. //-----------------------------------------------------------------------------------------
  121. // Function Prototypes
  122. //-----------------------------------------------------------------------------------------
  123.  
  124. SInt32 GetAddressType(UInt8 *);
  125. SInt32 BindTheStream(DLPIStream *, mblk_t *);
  126. SInt32 DoEnableMulticast(DLPIStream *, mblk_t *);
  127. SInt32 DoErrorAck(DLPIStream *, mblk_t *, UInt32, UInt32, UInt32);
  128. void FindStreamForReceivedPacket(DLPIStream *, mblk_t *);
  129. SInt32 DoGeneralInfo(DLPIStream *);
  130. void DoOKAck(DLPIStream *, mblk_t *, UInt32);
  131. SInt32 DoPhysicalAddressAck(DLPIStream *,mblk_t *);
  132. SInt32 SubsBindTheStream(DLPIStream *, mblk_t *);
  133. SInt32 UnSubsBindTheStream(DLPIStream *, mblk_t *);
  134. SInt32 SendTestPacket(DLPIStream *, mblk_t *, UInt8);
  135. Boolean TestGroupSAP(DLPIStream *, UInt8);
  136. SInt32 UnBindTheStream(DLPIStream *, mblk_t *);
  137. void DoUnitData(DLPIStream *, mblk_t *);
  138. SInt32 DoXID(DLPIStream *, mblk_t *, UInt8);
  139. SInt32 DoDisableMulticast(DLPIStream *, mblk_t *);
  140. mblk_t *BuildPacketHeader(DLPIStream *, mblk_t *, UInt8 *, UInt32, UInt8, UInt8,Boolean);
  141. SInt32 DoSetPhysicalAddress(DLPIStream *theStream, mblk_t *mp);
  142. SInt32 DoStatisticsAck(DLPIStream *theStream, mblk_t *mp); 
  143.  
  144.  
  145. mblk_t *BuildBindAck(DLPIStream *, UInt16);
  146. void BuildXidTestConfirmIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
  147. void ClearGroupSAP(DLPIStream *, UInt8);
  148. void EnableWriteQueue(long);
  149. SInt32 FindSnap(DLPIStream *, UInt8 *, SInt32);
  150. void SetGroupSAP(DLPIStream *, UInt8);
  151. mblk_t *BuildSubsBindAck(DLPIStream *, UInt8 *, SInt32);
  152. void DoTestResponse(DLPIStream *, mblk_t *);
  153. void DoUdError(DLPIStream *, UInt8 *, UInt32, UInt32, UInt32);
  154. void DoWriteScheduler(DLPIStream *, SInt32);
  155. void DoXidResponse(DLPIStream *, mblk_t *);
  156. UInt16 ClassifyPacketType(UInt16 primarySAP, UInt16 secondarySAP);
  157. mblk_t *ReuseMessageBlock(mblk_t *mp,UInt16 dataSizeNeeded);
  158. void BuildRxDestSrcHeader(T8022FullPacketHeader *packetHeader,T8022AddressStruct *destAddr,T8022AddressStruct *srcAddr,UInt32 dlsap_length);
  159. Boolean AreAllStreamsUnbound(void);
  160. void AddXIDInfoToPacketData(DLPIStream *theStream, mblk_t *headerMB, mblk_t *dataMB);
  161. void BuildUnitDataIndication(DLPIStream *theStream, mblk_t *mp, UInt16 destAddrLength, UInt16 headerHideLength);
  162. Boolean CheckAddressMatch(UInt8 *, UInt8 *, SInt32);
  163. void HandleReceivedPacket(DLPIStream *theStream, mblk_t *mp,UInt16 packetType);
  164. void ExtractSAPValues(T8022FullPacketHeader *fullpkt, UInt16 *sourceSAP, UInt16 *destSAP);
  165. mblk_t *BuildTxPacketHeader(DLPIStream *theStream, mblk_t *mp, Boolean forFastPathOnly);
  166. mblk_t *IsAddressRegistered(QHdr *multicastQueue,UInt8 *reqaddr, Boolean dequeueBlock,UInt16 interruptMask);
  167. UInt16 ClassifyRxPacket(mblk_t *thePacket);
  168.  
  169.